<template>
  <div class="page">
    <div class="banner"></div>
    <div class="rule"></div>
    <div class="value">
      <div class="con">
        <span class="icon"></span><span class="name">貢獻值：</span><span class="num">99.999</span>
      </div>
    </div>

    <div class="chains">
      <div class="item">
        <div class="icon"><img src="../assets/contribute/lock.png" alt=""></div>
        <span>未解鎖CFL</span></div>
      <div class="item">999.00</div>
      <div class="item">
        <div class="icon"><img src="../assets/contribute/unlock.png" alt=""></div>
        <span>可提取CFL</span></div>
      <div class="item">999.00</div>
    </div>
    <button class="to-cash" @click="showModal">
      <div class="icon"><img src="../assets/contribute/tocash.png" alt=""></div>
      <span>提取</span></button>
    <div class="tj">
      <div class="con">
        <div class="brand">
          我的推薦鏈接
        </div>
        <div class="link-box">
          <div class="text">http://www.googlegooglegoogle.com</div>
        </div>
        <button class="copy" @click="copy" data-clipboard-text="xxx"><span v-if="copySuccess" class="icon"><img
            src="../assets/contribute/check.png" alt=""></span>
          <span v-if="copySuccess">已複製</span>
          <span v-else>複製</span>
        </button>
      </div>
    </div>
    <TipModal ref="tip" modal-type="c"></TipModal>
  </div>
</template>

<script>
import Clipboard from 'clipboard'
import TipModal from "@/components/TipModal.vue";
export default {
  name: "contribute",
  components:{
    TipModal
  },
  data() {
    return {
      copySuccess: false
    }
  },
  methods: {
    copy() {
      const clip = new Clipboard('.copy')
      clip.on('success', e => {
        this.copySuccess = true;
      })
      clip.on('fail', e => {
        console.log('浏览器不支持')
        clip.destroy();
      })
    },
    showModal(){
      this.$refs.tip.open();
    }
  }
}
</script>

<style scoped lang="less">
.banner {
  background: url('@/assets/contribute/banner.png') no-repeat center;
  background-size: cover;
}

.rule {
  background: url('@/assets/contribute/rule.png') no-repeat center;
  background-size: cover;
  width: 400px;
  height: 200px;
  border-radius: 6px;
  margin-top: 14px;
}

.value {
  display: flex;

  .con {
    display: flex;
    justify-content: center;
    border-radius: 20px;
    background: #223354;
    margin: 16px auto 0;
    align-items: center;
    font-weight: 700;
    font-size: 24px;
    padding: 0 11px;
    height: 38px;

  }

  .icon {
    width: 21px;
    height: 20px;
    background: url("@/assets/contribute/zs.png") no-repeat center;
    background-size: cover;
  }

  .name {
    color: #FDAF19;
    margin-left: 5px;
  }

  .num {
    color: #fff;
  }
}

.chains {
  display: flex;
  flex-wrap: wrap;
  margin-top: 15px;
  border-radius: 6px;
  overflow: hidden;

  .item {
    line-height: 31px;
    color: #6E767D;
    flex-shrink: 0;
    width: calc(50% - 2px);
    margin-bottom: 2px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;

    &:nth-of-type(odd) {
      font-size: 12px;
      margin-right: 2px;
    }

    &:nth-of-type(even) {
      font-size: 14px;
      font-weight: bold;
      color: #9C27B0;
    }
  }

  .icon {
    width: 16px;
    height: 16px;
    margin-right: 10px;

    img {
      display: block;
      max-width: 100%;
      max-height: 100%;
    }
  }
}

.to-cash {
  width: 114px;
  height: 30px;
  margin: 22px auto;
  border-radius: 4px;
  opacity: 1;
  background: #9C27B0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  color: #fff;

  .icon {
    display: block;
    width: 16px;
    height: 16px;
    margin-right: 8px;

    img {
      display: block;
      max-height: 100%;
      max-width: 100%;
    }
  }
}

.tj {
  display: flex;
  justify-content: flex-end;

  .con {
    padding-left: 45px;
    height: 81px;
    border-radius: 5px;
    position: relative;
    width: 321px;
    background: #fff;
    display: flex;
    align-items: center;

    .brand {
      width: 41px;
      height: 60px;
      position: absolute;
      left: -36px;
      top: 7px;
      background: #E1BEE7;
      border-radius: 6px;
      padding: 4px 15px;
    }

    .link-box {
      width: 150px;
      height: 22px;
      padding: 10px 40px;
      border-radius: 4px;
      line-height: 22px;
      border: 1px solid #E1BEE7;
      outline: none;
      font-size: 12px;

      .text {
        max-width: 100%;
        max-height: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        color: #6E767D;
      }
    }

    .copy {
      display: flex;
      align-items: center;

      .icon {
        width: 14px;
        height: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 4px;

        img {
          display: block;
          max-width: 100%;
          max-height: 100%;
        }
      }

      background: #9C27B0;
      padding: 0 10px;
      height: 21px;
      line-height: 21px;
      border-radius: 4px;
      color: #fff;
      font-size: 12px;
      margin-left: 10px;
    }
  }
}
</style>